package com.hhs.storage.controller;


import com.hhs.storage.bean.BaseLogs;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.service.BaseLogsService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hhs
 * @since 2022-12-16
 */
@RestController
@RequestMapping("/logs")
public class BaseLogsController {
    @Resource
    private BaseLogsService baseLogsService;

    @RequestMapping(value = "table")
    public Map<String, Object> getAll(BaseLogs logs, InputParam inputParam) {
        baseLogsService.log("日志管理", "查询", null);
        return baseLogsService.getAll(logs, inputParam);
    }

    @PostMapping(value = "getByIdAll")
    public Map<String, Object> getByIdAll(String userId, String module, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate workDate, Boolean secondWeek) {
        return baseLogsService.getByIdAll(userId, module, workDate, secondWeek);
    }

    @PostMapping(value = "dayAll")
    public Map<String, Object> getDayAll(String date) {
        return baseLogsService.getDayAll(date);
    }

    @RequestMapping(value = "dele")
    public Map<String, Object> dele(@RequestParam String id) {
        baseLogsService.log("日志管理", "删除", null);
        return baseLogsService.dele(id);

    }

}

